/*登录页*/
require("../css/login.less")
//文档加载完毕
document.ready(function () {
    
    let PasTLogin=document.querySelector("#PasTLogin")
    
    PasTLogin.onclick=function(){
        window.location.href="./register.html"
    }
 

    let phonInp=document.querySelector("#phonInp")
    let pasitInt=document.querySelector("#pasitInt")
    let btn=document.querySelector("#btn")
    let tishi=document.querySelector(".tishi")

    // 登录验证
    btn.onclick=function(){
        //获取手机号
        let phone=phonInp.value
        //获取密码
        let pass=pasitInt.value
 

        if(!window.$utils.isphone(phone)){
            tishi.textContent="号码格式不正确"
        }else if(!window.$utils.ispassword(pass)){
            tishi.textContent="密码格式不正确"
        }else{
            console.log("发送ajax请求");
            axios.post("http://139.9.177.51:8099/users/login",{
                "account":phone,
                "password":pass
            }).then(function(res){
                let resdata=res.data
                console.log(res);
                if(resdata.status==0){
                    console.log(res.data);
                    window.localStorage.setItem("user",JSON.stringify(res.data.data.user))
                    window.$utils.Prompt("test","恭喜登录",2000)
                    setTimeout(function(){
                        window.location="./home.html"
                    },2500)
                }else if(resdata.status==555){
                    tishi.textContent=resdata.msg
                }
               
            }).catch(function(error){

            })
        }


    }


})
